<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title></title>
  <link rel="stylesheet" href="/Public/Admin/css/pintuer.css">
  <link rel="stylesheet" href="/Public/Admin/css/admin.css">
  <link rel="stylesheet" href="/Public/Admin/css/bootstrap.min.css">

  <link rel="stylesheet" href="/Public/Admin/css/fileinput.min.css">
  <script src="/Public/Admin/js/jquery.js"></script>
  <script src="/Public/Admin/js/pintuer.js"></script>
  <script src="/Public/Admin/js/fileinput.min.js"></script>
  <script src="/Public/Admin/js/pintuer.js"></script>
  <script src="http://www.jq22.com/jquery/bootstrap-3.3.4.js" type="text/javascript"></script>


  <style>
    .select {
      font-size: 14px;
      padding: 10px;
      border: solid 1px #ddd;
      line-height: 20px;
      display: block;
      border-radius: 3px;
    }
    .input-group {
      position: relative;
      display: table;
      width: 95%;
      float: left;
      /* margin: 0 0 0 2em; */
      border-collapse: separate;
    }
  </style>

</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>
    <?php if($info['id']): ?>修改<?php else: ?>增加<?php endif; ?>学生
  </strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="/Admin/Student/addStudent" enctype="multipart/form-data">
      <input type="hidden" class="input w50" value="<?php echo ($info["id"]); ?>" name="id"   />
      <div class="form-group">
        <div class="label">
          <label>学号：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="<?php echo ($info["student_id"]); ?>" name="student_id"  required />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>学生姓名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="<?php echo ($info["name"]); ?>" name="name"  required />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>学院：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="<?php echo ($info["college"]); ?>" name="college"  required />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>系部：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="<?php echo ($info["major"]); ?>" name="major"  required />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>班级：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="<?php echo ($info["class"]); ?>" name="class"  required />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>联系电话：</label>
        </div>
        <div class="field">
          <input type="number" class="input w50" value="<?php echo ($info["phone"]); ?>" name="phone"/>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>性别：</label>
        </div>
        <div class="field">
          <select name="sex" class="input w50">
            <option value="1" <?php if($info["sex"] == '1'): ?>selected<?php endif; ?>  >男</option>
            <option value="2" <?php if($info["sex"] == '2'): ?>selected<?php endif; ?> >女</option>
          </select>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>年龄：</label>
        </div>
        <div class="field">
          <input type="number" class="input w50" value="<?php echo ($info["age"]); ?>" name="age"/>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>邮箱：</label>
        </div>
        <div class="field">
          <input type="email" class="input w50" value="<?php echo ($info["email"]); ?>" name="email"/>
          <div class="tips"></div>
        </div>
      </div>
      <?php if($info["pic"] != null): ?><div class="form-group">
          <div class="label">
            <label>展示图片：</label>
          </div>
          <div class="field">
            <img src="<?php echo ($info["pic"]); ?>" width="60" height="60">
          </div>
        </div><?php endif; ?>
      <div class="form-group">
        <div class="label">
          <label>展示图片：</label>
        </div>
        <div class="field">
          <input type="file" class="button bg-blue margin-left" id="image1" name="pic" value="+ 浏览上传"  style="float:left;margin-left:0;">
          <div class="tipss">图片尺寸：60*60</div>
        </div>
      </div>
      <div style="border-bottom:1px solid #eee;margin-bottom:20px;"></div>

      <div class="text-center">
        <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
      </div>
    </form>
  </div>
</div>

<script>


  function depIdChange () {
    var depId = $("#dep_id").val();
    $.ajax({
      type:'get',
      dataType: 'json',
      url:"/Admin/Student/depClass",
      data:{
        'depId':depId
      },
      success:function(data){
        if(data){
          var html = '',v;
          for(var i =0; i<data.length ; i++){
            v = data[i];
            html += '<option value="'+v.id+'">'+v.name+'</option>';
          }
          $("#class_id").html(html);

          return true;
        } else{
          layer.msg("获取失败1",{icon: 2});
          return false;
        }
      },
      error:function(msg) {
        layer.msg('获取失败2',{icon: 2});
        return false;
      }
    });
  }

  function xuanze () {
    var if_send = $('#if_send').val();
    if (if_send == 1) {
      $('#send_money').prop("required", false);
    } else {
      $('#send_money').prop("required", true);
    }
  }

  $("body").bind("keydown",function(event){
    if (event.keyCode == 116) {
      event.preventDefault(); //阻止默认刷新
      //location.reload();
      //采用location.reload()在火狐下可能会有问题，火狐会保留上一次链接
      location=location;
    }
  })

  $("#file-1").fileinput({
    uploadUrl: '#', // you must set a valid URL here else you will get an error
    allowedFileExtensions : ['jpg', 'png','gif'],
    overwriteInitial: false,
    maxFileSize: 1000,
    maxFilesNum: 10,
    //allowedFileTypes: ['image', 'video', 'flash'],
    slugCallback: function(filename) {
      return filename.replace('(', '_').replace(']', '_');
    }
  });

</script>


<!-- 配置文件 -->
<script type="text/javascript" src="/Public/Admin/utf8-php/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/Public/Admin/utf8-php/ueditor.all.js"></script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/Public/Admin/utf8-php/lang/zh-cn/zh-cn.js"></script>


<!-- 实例化编辑器 -->
<script type="text/javascript">

  //实例化编辑器
  //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
  var ue = UE.getEditor('editor');


  function isFocus(e){
    alert(UE.getEditor('editor').isFocus());
    UE.dom.domUtils.preventDefault(e)
  }
  function setblur(e){
    UE.getEditor('editor').blur();
    UE.dom.domUtils.preventDefault(e)
  }
  function insertHtml() {
    var value = prompt('插入html代码', '');
    UE.getEditor('editor').execCommand('insertHtml', value)
  }
  function createEditor() {
    enableBtn();
    UE.getEditor('editor');
  }
  function getAllHtml() {
    alert(UE.getEditor('editor').getAllHtml())
  }
  function getContent() {
    var arr = [];
    arr.push("使用editor.getContent()方法可以获得编辑器的内容");
    arr.push("内容为：");
    arr.push(UE.getEditor('editor').getContent());
    alert(arr.join("\n"));
  }
  function getPlainTxt() {
    var arr = [];
    arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
    arr.push("内容为：");
    arr.push(UE.getEditor('editor').getPlainTxt());
    alert(arr.join('\n'))
  }
  function setContent(isAppendTo) {
    var arr = [];
    arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
    UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
    alert(arr.join("\n"));
  }
  function setDisabled() {
    UE.getEditor('editor').setDisabled('fullscreen');
    disableBtn("enable");
  }

  function setEnabled() {
    UE.getEditor('editor').setEnabled();
    enableBtn();
  }

  function getText() {
    //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
    var range = UE.getEditor('editor').selection.getRange();
    range.select();
    var txt = UE.getEditor('editor').selection.getText();
    alert(txt)
  }

  function getContentTxt() {
    var arr = [];
    arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
    arr.push("编辑器的纯文本内容为：");
    arr.push(UE.getEditor('editor').getContentTxt());
    alert(arr.join("\n"));
  }
  function hasContent() {
    var arr = [];
    arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
    arr.push("判断结果为：");
    arr.push(UE.getEditor('editor').hasContents());
    alert(arr.join("\n"));
  }
  function setFocus() {
    UE.getEditor('editor').focus();
  }
  function deleteEditor() {
    disableBtn();
    UE.getEditor('editor').destroy();
  }
  function disableBtn(str) {
    var div = document.getElementById('btns');
    var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
    for (var i = 0, btn; btn = btns[i++];) {
      if (btn.id == str) {
        UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
      } else {
        btn.setAttribute("disabled", "true");
      }
    }
  }
  function enableBtn() {
    var div = document.getElementById('btns');
    var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
    for (var i = 0, btn; btn = btns[i++];) {
      UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
    }
  }

  function getLocalData () {
    alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
  }

  function clearLocalData () {
    UE.getEditor('editor').execCommand( "clearlocaldata" );
    alert("已清空草稿箱")
  }
</script>

</body>
</html>